#include "TabControl.h"
#include "CommCtrl.h"

TabControl::TabControl(HWND a_hWnd, HINSTANCE a_hInst)
{
	m_hWnd = CreateWindow(WC_TABCONTROL, "", WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, 0, 500, 250, 768, a_hWnd, NULL, a_hInst, NULL);

	TCITEM tci;
	tci.mask = TCIF_TEXT;

	tci.pszText = "Player";
	TabCtrl_InsertItem(m_hWnd, 0, &tci);

	tci.pszText = "Terrain";
	TabCtrl_InsertItem(m_hWnd, 1, &tci);

	tci.pszText = "Rendering";
	TabCtrl_InsertItem(m_hWnd, 2, &tci);

	ChangeState(TC_ONE);
}
TabControl::~TabControl()
{

}
int TabControl::GetCurrentTabIndex()
{
	return TabCtrl_GetCurSel(m_hWnd);
}
void TabControl::ChangeState(tc_state a_state)
{
	m_currentState = a_state;
}
TabControl::tc_state TabControl::GetCurrentState()
{
	return m_currentState;
}
void TabControl::Update()
{
	//If the tab index has changed, update the current state to the new tab
	if(GetCurrentTabIndex() != m_currentState)
	{
		ChangeState((tc_state)GetCurrentTabIndex());
		
		//Do something to change what it contains
		//Destroy all windows, create the new ones based on what the current state is?
	}

	if(GetCurrentState() == TC_TWO)
	{
		//make controls for tab two etc...
	}
}